<template>
  <div>
    <p>我是弟弟组件的数据{{ count }}</p>
    <button @click="uninstall">点击卸载订阅</button>
  </div>
</template>

<script>
import PubSub from "pubsub-js";
export default {
  name: "List",
  data() {
    return {
      count: 0,
    };
  },
  mounted() {
    PubSub.subscribe("count", (_, count) => {
      this.count = count;
    });
  },
  methods: {
    uninstall() {
      PubSub.unsubscribe("count");
    },
  },
};
</script>

<style>
</style>